﻿var BasicPhysics = new function () {

    this.SPIN_DIRECTION_CLOCKWISE = 0;
    this.SPIN_DIRECTION_COUNTER_CLOCKWISE = 1;

    this.RotationNextPosition = function (currentPosition, center, radius, speed, direction) {

        var fps = 30;

        var currentAngleInRadians = Math.atan2(currentPosition.Y - center.Y, currentPosition.X - center.X);

        if (direction == this.SPIN_DIRECTION_COUNTER_CLOCKWISE)
            currentAngleInRadians = -currentAngleInRadians;

        var rotationForStep = speed / fps;
        var rotationStepInRadians = rotationForStep * Math.PI * 2;
        var newAngle = currentAngleInRadians + rotationStepInRadians;
        if (direction == this.SPIN_DIRECTION_COUNTER_CLOCKWISE)
            newAngle = -newAngle;

        var nextPosition = new Point(radius * Math.cos(newAngle) + center.X, radius * Math.sin(newAngle) + center.Y);

        return nextPosition;
    };
    
    this.VectorNextPosition = function(currentPosition, vector){
    	
    	return new Point(currentPosition.X + vector.A, currentPosition.Y + vector.B);
    	
    };

};